package com.cx330;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Example61 {
    @Test
    public void test1() {
        ArrayList<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        Object[] array = list.toArray();
        System.out.println(Arrays.toString(array));
    }

    @Test
    public void test2() {
        ArrayList<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        String[] array = new String[0];
        array = list.toArray(array);
        System.out.println(Arrays.toString(array));
    }

    @Test
    public void test3() {
        String[] array = {"aaa", "bbb", "ccc"};
        List<String> list = Arrays.asList(array);
        ArrayList<String> arrayList = new ArrayList<>(list);
    }

    @Test
    public void test4() {
        String[] array = {"aaa", "bbb", "ccc"};
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, array);
    }
}
